package service

import (
	"context"
	"ruoyi-go-echo-ddd/internal/domain/model"
	"ruoyi-go-echo-ddd/internal/domain/repository"
	"ruoyi-go-echo-ddd/internal/infrastructure/http/request"
)

type SysPostService struct {
	repo repository.SysPostRepository
}

func NewSysPostService(repo repository.SysPostRepository) *SysPostService {
	return &SysPostService{repo: repo}
}

func (s *SysPostService) Insert(ctx context.Context, sysPost *model.SysPost) (*model.SysPost, error) {
	return s.repo.Insert(ctx, sysPost)
}

func (s *SysPostService) Update(ctx context.Context, sysPost *model.SysPost) (int64, error) {
	return s.repo.Update(ctx, sysPost)
}

func (s *SysPostService) BatchInsert(ctx context.Context, list []*model.SysPost) ([]int64, error) {
	return s.repo.BatchInsert(ctx, list)
}

func (s *SysPostService) SelectById(ctx context.Context, id int64) (*model.SysPost, error) {
	return s.repo.SelectById(ctx, id)
}

func (s *SysPostService) SelectPage(ctx context.Context, param *request.PostPageParam) ([]*model.SysPost, int64, int64, error) {
	return s.repo.SelectPage(ctx, param)
}

func (s *SysPostService) BatchDelete(ctx context.Context, ids []any) (int64, error) {
	return s.repo.BatchDelete(ctx, ids)
}

func (s *SysPostService) SelectPostIdsByUserId(ctx context.Context, userId int64) ([]int64, error) {
	return s.repo.SelectPostIdsByUserId(ctx, userId)
}

func (s *SysPostService) SelectPostNameListByIds(ctx context.Context, ids []int64) ([]string, error) {
	return s.repo.SelectPostNameListByIds(ctx, ids)
}

func (s *SysPostService) SelectAll(ctx context.Context) ([]*model.SysPost, error) {
	return s.repo.SelectAll(ctx)
}

func (s *SysPostService) DeleteByUserId(ctx context.Context, userId int64) (int64, error) {
	return s.repo.DeleteByUserId(ctx, userId)
}

func (s *SysPostService) DeleteByUserIdList(ctx context.Context, userIds []int64) (int64, error) {
	return s.repo.DeleteByUserIdList(ctx, userIds)
}
